//=============================================================================
//                                                                            
//   Exercise code for the lecture
//                                                                            
//=============================================================================
//=============================================================================
//
//  CLASS ProceduralViewer
//
//=============================================================================


#ifndef PROCEDURAL_VIEWER_HH
#define PROCEDURAL_VIEWER_HH


//== INCLUDES =================================================================
#include <string>
#include <vector>

#include "../../gl/TrackballViewer.h"
#include "../../gl/shader.h"
#include "../../gl/Mesh3D.h"
#include "../../gl/Light3D.h"
#include "../../gl/texture.h"

//== CLASS DEFINITION =========================================================
	      
/*
 ProceduralViewer.
*/
class ProceduralViewer : public TrackballViewer
{
public:
   
	ProceduralViewer(const char* _title, int _width, int _height);
  
	void loadMesh(const std::string& filenameObj);

protected:

	// overloaded GUI function
	virtual void init();
	virtual void keyboard(int key, int x, int y);
	virtual void special(int key, int x, int y);

	virtual void draw_scene(DrawMode _draw_mode);

protected:
	std::vector<float> createColorMapTexture( int mapSize, const Vector3 * discreteColorMap, int outputTextureSize );
    

protected:
	
	// mesh object
	Mesh3D m_mesh;

	// procedural shader
	Shader m_proceduralShader;
	
	// Textures
	Texture m_permutationTable;
	Texture m_gradient2DTable;
	Texture m_gradient3DTable;
	Texture m_gradient4DTable;
	
	Texture m_colorMap;
	
};


//=============================================================================
#endif // PROCEDURAL_VIEWER_HH defined
//=============================================================================
